package com.yequan.work;

import java.util.Objects;

/**
 * @author yequan
 * @date 2021/11/06 16:15
 **/
public class SafetyRecordThreadLocal {

    public static final ThreadLocal<Boolean> local = new ThreadLocal<>();

    public static void putReturnNow(boolean returnNow) {
        local.set(returnNow);
    }

    public static boolean getReturnNow() {
        Boolean returnNowObj = local.get();
        if (Objects.isNull(returnNowObj)) {
            return false;
        }
        return returnNowObj;
    }

    public static void main(String[] args) {
        System.out.println(getReturnNow());
        putReturnNow(true);
        System.out.println(getReturnNow());
    }

}
